package com.lucien.system.service.impl;

import com.lucien.system.domain.MessageType;
import com.lucien.system.domain.MessageTypeExample;
import com.lucien.system.mapper.MessageTypeMapper;
import com.lucien.system.service.MessageTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author Lucien
 * @Date 2021/5/30 11:22
 * @Version 1.0
 * @Description:
 */
@Service
public class MessageTypeServiceImpl implements MessageTypeService {

    @Autowired
    private MessageTypeMapper typeMapper;

    /**
     * 获取messagetype ID
     * @param name
     * @return
     */
    @Override
    public Integer getTypeId(String name) {
        MessageTypeExample example = new MessageTypeExample();
        MessageTypeExample.Criteria criteria = example.createCriteria();
        criteria.andNameEqualTo(name);

        List<MessageType> types = typeMapper.selectByExample(example);

        return types.get(0).getId();
    }
}
